package exp2;
import org.junit.Test;

/**
 * Created by radish608 on 17-5-3.
 */
public class ComplexTest {
    Complex num1 = new Complex();
    Complex num2 = new Complex(1,1);
    Complex num3 = new Complex(1.1,0.9);
    Complex num4 = new Complex(2.0,5.1);
    @Test
    public void getA()  {
        assert num1.getA() == 0 : "error1:getA or Complex()";
        assert num2.getA() == 1 : "error1:getA or Complex(double a, double b)";
        assert num3.getA() == 1.1 : "error1:getA or Complex(double a, double b)";
        assert num4.getA() == 2.0 : "error1:getA or Complex(double a, double b)";
    }

    @Test
    public void setA() {
        assert num1.setA(2.0) == 2.0 : "error2:setA";
        assert num2.setA(0) == 0 : "error2:setA";
        assert num3.setA(1) == 1 : "error2:setA";
        assert num4.setA(1.1) == 1.1 : "error2:setA";
    }

    Complex num5 = new Complex();
    Complex num6 = new Complex(1,1);
    Complex num7 = new Complex(1.1,0.9);
    Complex num8 = new Complex(2.0,5.1);
    Complex num9 = new Complex();
    Complex num10 = new Complex();
    Complex num11 = new Complex();
    Complex num12 = new Complex();

    @Test
    public void complexAdd() {
        num12 = num10.ComplexAdd(num11);
        num9 = num5.ComplexAdd(num6);
        num10 = num6.ComplexAdd(num7);
        num11 = num7.ComplexAdd(num8);

        assert num9.getA() == 1 : "error3:ComplexAdd" ;
        assert num9.getB() == 1 : "error3:ComplexAdd" ;

        assert num10.getA() == 2.1 : "error3:ComplexAdd" ;
        assert num10.getB() == 1.9 : "error3:ComplexAdd" ;

        assert num11.getA() == 3.1 : "error3:ComplexAdd" ;
        assert num11.getB() == 6.0 : "error3:ComplexAdd" ;

        assert num12.getA() == 0 : "error3:ComplexAdd" ;
        assert num12.getB() == 0 : "error3:ComplexAdd" ;
    }
}